package com.guang.springbootexception.exception;

/**
 * 日志也会有对应的记录信息
 */
public enum ServiceExceptions {
    SSSS(0, "处理成功"),
    F999(999, "系统未知异常"),
    S001(101, "调用异常相关"),
    S002(102, "参数传递异常相关"),
    S003(103, "数据错误相关"),
    S004(104, "异步执行异常"),
    S005(105, "解析请求失败"),
    F001(201, "具体系统异常相关");

    private Integer errCode;
    private String errMsg;

    private ServiceExceptions(Integer errCode, String errMsg) {
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public Integer getErrCode() {
        return this.errCode;
    }

    public String getErrMsg() {
        return this.errMsg;
    }

    public ServiceException buildServiceException(String errMsg) {
        return new ServiceException(this.errCode, errMsg);
    }

    public ServiceException buildServiceException(String errMsg, Throwable t) {
        return new ServiceException(this.errCode, errMsg, t);
    }

    public ServiceException buildServiceException() {
        return new ServiceException(this.errCode, this.errMsg);
    }

    public ServiceException buildServiceException(Throwable t) {
        return new ServiceException(this.errCode, this.errMsg, t);
    }

    public static ServiceExceptions findServiceExceptions(Integer errCode) {
        if (errCode == null) {
            return null;
        } else {
            ServiceExceptions[] var1 = values();
            int var2 = var1.length;

            for(int var3 = 0; var3 < var2; ++var3) {
                ServiceExceptions serviceExceptions = var1[var3];
                if (serviceExceptions.getErrCode().equals(errCode)) {
                    return serviceExceptions;
                }
            }

            return null;
        }
    }
}